{% extends 'myadmin/base.html' %}
{% block main_body %}
<style>
    .form-card {
        background: #fff;
        border-radius: 6px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        padding: 20px;
    }
    .form-section {
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 1px solid #f1f1f1;
    }
    .form-group {
        margin-bottom: 15px;
    }
    .form-group label {
        font-weight: 600;
        margin-bottom: 5px;
        display: block;
    }
    .form-control {
        width: 100%;
        padding: 6px 10px;
        font-size: 13px;
        height: 34px;
        box-sizing: border-box;
        border: 1px solid #ccc;
        border-radius: 4px;
    }
    .required-mark {
        color: #dd4b39;
        margin-left: 3px;
    }
    .btn-group {
        margin-top: 15px;
        display: flex;
        gap: 10px;
        justify-content: flex-end;
    }
</style>

<section class="content-header">
    <h1>食谱管理 <small>添加食材</small></h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-home"></i> 首页</a></li>
        <li><a href="#">食谱管理</a></li>
        <li><a href="{% url 'myadmin_recipes_detail' recipe.recipe_id %}">食谱详情</a></li>
        <li class="active">添加食材</li>
    </ol>
</section>

<section class="content">
    <div class="row">
        <div class="col-md-6">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">为食谱添加食材</h3>
                    <p>当前食谱：{{ recipe.recipe_name }}</p>
                </div>
                <form method="post" action="{% url 'myadmin_recipes_ingredient_insert' recipe.recipe_id %}" class="form-card">
                    {% csrf_token %}

                    <div class="form-section">
                        <div class="form-group">
                            <label>食材选择 <span class="required-mark">*</span></label>
                            <select name="food_id" class="form-control" required>
                                <option value="">-- 请选择食材 --</option>
                                {% for food in foods %}
                                <option value="{{ food.food_id }}">{{ food.food_name }}</option>
                                {% endfor %}
                            </select>
                        </div>
                        
                        <div class="form-group">
                            <label>数量 <span class="required-mark">*</span></label>
                            <input type="number" name="quantity" class="form-control" min="0.01" step="0.01" required>
                        </div>
                        
                        <div class="form-group">
                            <label>单位</label>
                            <input type="text" name="unit" class="form-control" value="g" placeholder="例如：g、ml、个">
                        </div>
                    </div>

                    <div class="btn-group">
                        <button type="button" class="btn btn-default" onclick="window.history.back();">返回</button>
                        <button type="reset" class="btn btn-default">重置</button>
                        <button type="submit" class="btn btn-primary">添加食材</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
{% endblock %}